export default {
    data() {
        return {
            info: "",
            Ranking: [],
            recommend: [{
                url: "",
                author: ""
            }],
            textarea: '',
            clean: "",
            comment: {
                content: "",
                nick: "",
                date: ""
            },
            status: "购买",
            book: {
                title: "",
                classify: "",
                author: "",
                money: "",
                url: "",
                introduction: ""
            }
        }
    },
    methods: {
        on() {
            console.log(this.textarea)
            this.comment.content = this.textarea
            this.textarea = ""
        },
        readtest() {
            location.href = "/readtest" + location.search
        },
        buy() {
            this.$confirm('确认花费' + this.book.money + "购买本书吗？")
                .then(_ => {
                    this.axios.get("http://localhost:8088/buyBook?money=" + this.book.money).then((response) => {
                        let responseData = response.data;
                        if (responseData.state == 50003) {
                            console.log(responseData.state)
                            this.$message({
                                message:responseData.message,
                                type: 'warning'
                            })
                        } else {
                            this.status = "已购买";
                            this.$message({
                                message: '购买成功！',
                                type: 'success'
                            })
                        }
                    })
                })
        }

    },
    created: function () {

        this.axios.get("http://localhost:8088/bookById" + location.search).then((response) => {
            this.book = response.data;
        })

    }
}